package de.ralbus.stellplatz.maps;

import android.content.Context;
import android.graphics.Canvas;
import android.graphics.Paint;
import android.graphics.Point;

import com.google.android.maps.GeoPoint;
import com.google.android.maps.MapView;
import com.google.android.maps.Overlay;



public class MapOverlayTouch extends Overlay{
	private GeoPoint geoPoint;
	@SuppressWarnings("unused")
	private Context context;
	public MapOverlayTouch(Context context){
		this.context=context;
	}
	public double lat = 0.0;
	public double lon = 0.0;
	
	@Override
	public boolean draw(Canvas canvas, MapView mapView, boolean shadow,
			long when) {
		super.draw(canvas, mapView, shadow, when);
		if(shadow == false && geoPoint != null){
			Point screenPoint = new Point();
			mapView.getProjection().toPixels(geoPoint, screenPoint);
			//add the Marker
			Paint paint = new Paint();
			paint.setARGB(255, 255, 0, 0); //gelb ist 255,255,255,0
			canvas.drawCircle(screenPoint.x, screenPoint.y, 10, paint);	
			canvas.drawText("Hier suchen", screenPoint.x+10, screenPoint.y, paint);
		}
		return true;
	}
	@Override
	public boolean onTap(GeoPoint geoPoint, MapView mapView) {
		this.geoPoint=geoPoint;
		lat = geoPoint.getLatitudeE6()/1E6;
		lon = geoPoint.getLongitudeE6()/1E6;
		 //on Touch suchen im context
//		String coords ="lat: "+ geoPoint.getLatitudeE6()/1E6 +"\nlon: "+ geoPoint.getLongitudeE6()/1E6;
//		Toast.makeText(context, coords, Toast.LENGTH_LONG).show();
		return true;
	}
	
}
